package com.meeting.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.meeting.common.result.Result;
import com.meeting.model.dto.meetingroom.MeetingRoomQueryRequest;
import com.meeting.model.vo.MediaDeviceTypeVO;
import com.meeting.model.vo.MeetingRoomAndStatusVO;
import com.meeting.service.MediaDeviceTypeService;
import com.meeting.service.MeetingRoomService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/common")
@Tag(name = "公共接口")
public class CommonController {

    @Resource
    private MediaDeviceTypeService mediaDeviceTypeService;

    @Resource
    private MeetingRoomService meetingRoomService;

    @GetMapping("/media")
    @Operation(summary = "获取会议室多媒体设备列表", description = "根据会议室id获取会议室多媒体设备列表")
    public Result<List<MediaDeviceTypeVO>> getMediaDeviceTypeList(@Valid @NotNull(message = "会议室id缺失") Integer meetingRoomId) {
        return mediaDeviceTypeService.getMediaDeviceTypeListByMeetingRoomId(meetingRoomId);
    }

    @PostMapping("meeting-room")
    @Operation(summary = "获取所有会议室信息", description = "可以根据条件获取所有会议室信息")
    public Result<Page<MeetingRoomAndStatusVO>> getMeetingRoom(@RequestBody MeetingRoomQueryRequest queryRequest) {
        long pageNum = queryRequest.getPageNum();
        long pageSize = queryRequest.getPageSize();
        Page<MeetingRoomAndStatusVO> page = meetingRoomService.queryMeetingRoom(new Page<>(pageNum, pageSize), queryRequest);
        return Result.success(page);
    }
}
